/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package reflect;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 *
 * @author Administrator
 */
public class Hello {


    private String 我是成员 = "???";
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException, Exception {
        
//        FileOutputStream fp = new FileOutputStream("C:\\2.txt");
//        
//        List<String> txt = Files.readAllLines(Paths.get("C:\\1.txt"));
//        List<String[]> result = new ArrayList<String[]>();
//        for (int i = 0; i < txt.size(); i ++) {
//            String[] temp = txt.get(i).split("\\s+");
//            Double[] d = new Double[3];
//            String[] s = new String[3];
//            for (int j = 0; j < 3; j ++) {
//                try {
//                    d[j] = Double.valueOf(temp[j]);
//                } catch (Exception e) {
//                    System.out.print("错误" + i);
//                }
//            }
//            if (d[0] < 0.0) {
//                d[0] = -d[0];
//            }
//            if (d[1] < 0.0) {
//                d[1] = -d[1];
//            }
//            if (d[2] > 0.0) {
//                d[2] = - d[2];
//            }
//            for (int k = 0; k < 3; k ++) {
//                s[k] = " " + d[k];
//            }
//            result.add(s);
//        }
//        for (String[] strings : result) {
//            //System.out.println(Arrays.toString(strings));
//            writeData(fp, strings);
//        }
//        fp.close();
//        System.out.println("成功！！");
           gai();
    }
    
    public static void writeData(FileOutputStream fos, String[] s) throws IOException {
        byte[] b = new byte[512];
        String t = s[0] + " " + s[1] + " " + s[2] + "\n";
        //System.out.println(t);
        b = t.getBytes();
        fos.write(b, 0, t.length());
    }
    
    public static void gai() throws Exception{
    
        FileOutputStream fp = new FileOutputStream("C:\\3.txt");
        
        List<String> txt = Files.readAllLines(Paths.get("C:\\1.txt"));
        List<String[]> result = new ArrayList<String[]>();
        for (int i = 0; i < txt.size(); i ++) {
            String[] temp = txt.get(i).split("\\s+");
            Double[] d = new Double[3];
            String[] s = new String[3];
            for (int j = 0; j < 3; j ++) {
                d[j] = Double.valueOf(temp[j]);
            }
            if (d[0] < 0.0 && d[1]<0.0 && d[2]>0.0) {
                d[0] = -d[0];
				d[1] = -d[1];
				d[2] = -d[2];
            }
			for (int u = 0; u < 3; u ++) {
                d[u] = Double.valueOf(temp[u]);
            }
            if (d[0] > 0.0 && d[1]<0.0 && d[2]>0.0) {
                d[0] = -d[0];
				d[1] = -d[1];
				d[2] = -d[2];
            }
            /*if (d[1] < 0.0) {
                d[1] = -d[1];
            }
            if (d[2] > 0.0) {
                d[2] = - d[2];
            }*/
            for (int k = 0; k < 3; k ++) {
                s[k] = " " + d[k];
            }
            result.add(s);
        }
        for (String[] strings : result) {
            //System.out.println(Arrays.toString(strings));
            writeData(fp, strings);
        }
        fp.close();
        System.out.println("成功！！");
        
    }
}
